<?php
include_once("connect.php");
include_once ("log_order.php"); //test!

$order_id=$_GET['id'];

$sql = "SELECT * FROM order_list WHERE id=$order_id";
$rs = mysql_query($sql);
if ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {	

	$shipper = $row['shipper'];
	$address_id1 = $row['address_from_id'];
	$address_id2 = $row['address_to_id'];

	$package_name=$row['package_name'];
	$package_weight=$row['package_weight'];
	$package_length=$row['package_length'];
	$package_width=$row['package_width'];
	$package_height=$row['package_height'];
	$package_seq=$row['package_seq'];
	
	$item1_id = $row['item1_id'];
	$item2_id = $row['item2_id'];
	$item3_id = $row['item3_id'];
	
	$user_id = $row['order_user_id'];
	$time_create = $row['time_create'];	
	$time_finish = $row['time_finish'];	


	//--------------------		
	$user_login = '';
	$user_email = '';
	if ($user_id > 0){
		$sql = "select * from zy_users where ID=".$user_id;
		$rs=mysql_query($sql);
		if ($row1 = mysql_fetch_array($rs, MYSQL_ASSOC)) {
			$user_email=$row1['user_email'];
			$user_login=$row1['user_login'];
		}
	}
	
	//---
	$fee_sum = '';
	$fee_currency = '';
	$fee_currency_key = $row['fee_currency'];
	if($row['fee_currency']==1){
		$fee_sum = '￥'.$row['fee_sum'];		
		$fee_currency = '人民币';
	}else if ($row['fee_currency']==2){
		$fee_sum = '€'.$row['fee_sum'];
		$fee_currency = '欧元';
	}
	
	$fee_status = '';
	$fee_mode = '';
	$fee_pay = '';		
	$fee_add = '';
	$time_fee = '';
	$fee_mode_key = $row['fee_mode'];	
	$fee_pay_value = $row['fee_pay'];
	$fee_add_value = $row['fee_add'];
	switch ($row['order_status']) {
		case 10: 
		case 20 :
			$fee_status = '未支付';
			$fee_currency = '';
			break;					
		case 40 : 
			$fee_status = '待补款';
			$time_fee = $row['time_fee'];
			if($row['fee_mode']==1){
				$fee_mode = '支付宝';
			}else if($row['fee_mode']==2){
				$fee_mode = '信用卡';
			}			
			if($row['fee_currency']==1){	
				$fee_pay = '￥'.$row['fee_pay'];			
				$fee_add = ' &nbsp;&nbsp;待补款￥'.$row['fee_add'];
			}else if ($row['fee_currency']==2){
				$fee_pay = '€'.$row['fee_pay'];
				$fee_add = ' &nbsp;&nbsp;待补款€'.$row['fee_add'];
			}
			break;
		case 30 : 
		case 45 :
			$fee_status = '已支付';
			$time_fee = $row['time_fee'];
			if($row['fee_mode']==1){
				$fee_mode = '支付宝';
			}else if($row['fee_mode']==2){
				$fee_mode = '信用卡';
			}
			if($row['fee_currency']==1){	
				$fee_pay = '￥'.$row['fee_pay'];			
			}else if ($row['fee_currency']==2){
				$fee_pay = '€'.$row['fee_pay'];
			}
			break;	
	}
	
	$fee_add_value = '';
	if ($row['fee_add'] >0 ){
		$fee_add_value = $row['fee_add'];
	}
		
		
	//---
	$order_status_key = $row['order_status'];
	$order_status = '待定'; 	
	switch ($row['order_status']) {
		case 10 : 
			$order_status = '新建订单，待录入信息（尊敬的客户，您的订单信息没完整录入，请继续填写）';
			break;					
		case 20 : 
			$order_status = '信息填写完成，待付款（尊敬的客户，您的订单信息录入完成，可以进行支付）';
			$order_status .= '<a href=https://shenghuo.alipay.com/send/payment/fill.htm?_tosheet=true target=_blank>点击支付</a>';
			break;
		case 30 : 
		case 45 :
			$order_status = '已付款的订单（尊敬的客户，您的订单已经支付完成，我们的工作人员正在安排抓紧派送）';
			break;					
		case 40 : 
			$order_status = '款项不足，待补款（尊敬的客户，您支付的款项不足'.$fee_add.'）';
			$order_status .= '<a href=https://shenghuo.alipay.com/send/payment/fill.htm?_tosheet=true target=_blank>点击支付</a>';
			break;
		case 50 : 
			$order_status = '订单已结束（尊敬的客户，您的订单已在$time_finish结束）';
			break;					
	}
	

	//-----------------------------------------------
	$idc_name1 = '';	
	$country1 = '';
	$city1 = '';
	$address1 = '';
	$postcode1 = ''; 
	$tel1 = '';
	$email1 = '';
	$door_num1 = '';
	if($address_id1>0){	
		$sql = "SELECT * FROM order_address WHERE order_user_id=$user_id AND id=$address_id1";	
		$rs = mysql_query($sql);
		if ($row1 = mysql_fetch_array($rs, MYSQL_ASSOC)) {		
			$idc_name1 = $row1['idc_name'];
			$country1 = $row1['country'];
			$city1 = $row1['city'];
			$address1 = $row1['address'];
			$postcode1 = $row1['postcode'];
			$tel1 = $row1['tel'];
			$email1 = $row1['email'];
			$door_num1 = $row1['door_num'];		
		} 
	}

	$idc_name2 = '';	
	$country2 = '';
	$province2 = '';
	$city2 = '';
	$address2 = '';
	$postcode2 = ''; 
	$tel2 = '';
	$email2 = '';
	if($address_id2>0){	
		$sql = "SELECT * FROM order_address WHERE order_user_id=$user_id AND id=$address_id2";	
		$rs = mysql_query($sql);
		if ($row2 = mysql_fetch_array($rs, MYSQL_ASSOC)) {		
			$idc_name2 = $row2['idc_name'];
			$country2 = $row2['country'];
			$province2 = $row2['province'];
			$city2 = $row2['city'];
			$address2 = $row2['address'];
			$postcode2 = $row2['postcode'];
			$tel2 = $row2['tel'];
			$email2 = $row2['email'];				
		} 	
	}	
		
	
	//-----------------------------------------------
	$item_name1 = '';
	$item_madein1 = '';
	$item_amount1 = '';
	$item_pre_weight1 = '';
	$item_pre_price1 = '';
	$item_weight1 = '';
	$item_price1 = '';	
	if($item1_id>0){
		$sql = "SELECT * FROM order_item WHERE id=$item1_id";	
		$rs = mysql_query($sql);
		if ($row1 = mysql_fetch_array($rs, MYSQL_ASSOC)) {			
			$item_name1 = $row1['item_name'];
			$item_madein1 = $row1['item_madein'];
			$item_amount1 = $row1['item_amount'];
			$item_pre_weight1 = $row1['item_pre_weight'];
			$item_pre_price1 = $row1['item_pre_price'];
			$item_weight1 = $row1['item_weight'];
			$item_price1 = $row1['item_price'];			
		} 	
	}

	$item_name2 = '';
	$item_madein2 = '';
	$item_amount2 = '';
	$item_pre_weight2 = '';
	$item_pre_price2 = '';
	$item_weight2 = '';
	$item_price2 = '';	
	if($item2_id>0){
		$sql = "SELECT * FROM order_item WHERE id=$item2_id";	
		$rs = mysql_query($sql);
		if ($row2 = mysql_fetch_array($rs, MYSQL_ASSOC)) {			
			$item_name2 = $row2['item_name'];
			$item_madein2 = $row2['item_madein'];
			$item_amount2 = $row2['item_amount'];
			$item_pre_weight2 = $row2['item_pre_weight'];
			$item_pre_price2 = $row2['item_pre_price'];
			$item_weight2 = $row2['item_weight'];
			$item_price2 = $row2['item_price'];			
		} 	
	}
	
	$item_name3 = '';
	$item_madein3 = '';
	$item_amount3 = '';
	$item_pre_weight3 = '';
	$item_pre_price3 = '';
	$item_weight3 = '';
	$item_price3 = '';	
	if($item3_id>0){
		$sql = "SELECT * FROM order_item WHERE id=$item3_id";	
		$rs = mysql_query($sql);
		if ($row3 = mysql_fetch_array($rs, MYSQL_ASSOC)) {			
			$item_name3 = $row3['item_name'];
			$item_madein3 = $row3['item_madein'];
			$item_amount3 = $row3['item_amount'];
			$item_pre_weight3 = $row3['item_pre_weight'];
			$item_pre_price3 = $row3['item_pre_price'];
			$item_weight3 = $row3['item_weight'];
			$item_price3 = $row3['item_price'];			
		} 	
	}

} 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="hello" />
<meta name="description" content="Hello" />
<title>order_item</title>

<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/fancybox.css" />

<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-cn.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="js/jquery.fancybox.js" type="text/javascript"></script>
<script src="js/jquery.message.js" type="text/javascript"></script>

<style type="text/css">
table{width:100%; margin:0px auto; border-collapse:collapse;}
table td{line-height:22px; padding:2px; padding-left:8px; border:1px solid #b6d6e6;}
.table_title{height:26px; line-height:26px; background:url(css/btn_bg.gif) repeat-x bottom; font-weight:bold; text-indent:.3em; outline:0;}
.table_label2{background:#e8f5fe; text-align:center; }
.table_label{background:#e8f5fe; text-align:right; }
.table_line{ text-align:center; font-weight:bold;}
.btn{height:24px; background:url(css/btn_bg.gif) repeat-x; padding:0 4px; font-size:12px; border:1px solid #ccc; cursor:pointer; margin-left:3px}
.input{border:1px solid #369; background:#ffc; padding:2px}
.msg{padding-left:30px; margin-top:20px}
textarea{font-size:12px}
</style>

<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript">
$(function(){
	$("#cancle_btn").click(function(){
		//window.history.back(-1); 
		self.location='order_list.php';
	});

});
</script>
</head>

<body>

<div id="main">

 <h2 class="top_title">我的订单&gt; 订单详细 &gt; 订单号：<?php echo $order_id; ?>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
 订单总金额：<?php echo $fee_sum; ?> </h2> 


<!-- <li><strong>订单号：<?php echo $order_id; ?></strong></li>  -->
<li><strong>订单状态：</strong> <?php echo $order_status; ?></li>

<!-- <li><strong>订单信息</strong></li>  -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
	<tbody>
	<tr>
		<td class="edit"  width="20%" valign="top">
			<strong>基本信息</strong>
			<br>订单创建用户：<?php echo $user_login; ?>
			<br>联系email：<?php echo $user_email; ?>
			<br>订单创建时间：<?php echo $time_create; ?>
			<br>寄件人国家：<?php echo $country1; ?>
			<br>收件人国家：<?php echo $country2; ?>
		</td>
		<td class="edit" width="20%" valign="top">
			<strong>支付信息</strong>
			<br>支付状态：<?php echo $fee_status; ?>
			<br>支付币种：<?php echo $fee_currency; ?>			
			<br>支付金额：<?php echo $fee_pay.$fee_add; ?>
			<br>支付方式：<?php echo $fee_mode; ?>
			<br>支付时间：<?php echo $time_fee; ?>
		</td>
		<td class="edit"  width="20%" valign="top">

		</td>	 
    </tr>	
	</tbody>
</table>


  
<li><strong>包裹信息</strong></li>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
	<tbody>
	<tr>
		<td class="edit"  width="20%" valign="top">
			<strong>寄件人信息</strong>
			<br>寄件人：		<?php echo $idc_name1; ?>
			<br>国家/地区：	<?php echo $country1; ?>
			<br>城市：  		<?php echo $city1; ?>
			<br>门牌号：		<?php echo $door_num1; ?>
			<br>地址：		<?php echo $address1; ?>
			<br>邮编：		<?php echo $postcode1; ?>
			<br>联系电话：	<?php echo $tel1; ?>
			<br>联系email：	<?php echo $email1; ?>
		</td>
		<td class="edit" width="20%" valign="top">
			<strong>收件人信息</strong>
			<br>收件人：		<?php echo $idc_name2; ?>
			<br>国家/地区：	<?php echo $country2; ?>
			<br>省份：		<?php echo $province2; ?>
			<br>城市：  		<?php echo $city2; ?>			
			<br>地址：		<?php echo $address2; ?>
			<br>邮编：		<?php echo $postcode2; ?>
			<br>联系电话：	<?php echo $tel2; ?>
			<br>联系email：	<?php echo $email2; ?>
		</td>
		<td class="edit"  width="20%" valign="top">
			<strong>包裹信息</strong>
			<br>承运物流商：		<?php echo $shipper; ?>
			<br>包裹号：			<?php echo $package_seq; ?>
			<br>包裹总重(公斤)：	<?php echo $package_weight; ?>
			<br>包裹长(厘米)：	<?php echo $package_length; ?>
			<br>包裹宽(厘米)：	<?php echo $package_width; ?>
			<br>包裹高(厘米)：	<?php echo $package_height; ?>
			<br>物品名称： 		<?php echo $package_name; ?> 
		</td>	 
    </tr>	
	</tbody>
</table>  
  
 

<li><strong>物品清单</strong></li>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
	<tbody>
	<tr>
		<td class="table_label2"  width="15%">物品名称
		</td>
		<td class="table_label2"  width="10%">物品数量
		</td>
		<td class="table_label2"  width="10%">单位净重(公斤)
		</td>
		<td class="table_label2"  width="15%">物品原产地
		</td>
		<td class="table_label2"  width="10%">物品单价(欧元)
		</td>
		<td class="table_label2"  width="10%">物品总价(欧元)
		</td>
		<td class="table_label2"  width="10%">物品总重(公斤)
		</td>
    </tr>

	<tr>
		<td class="eidt"><?php echo $item_name1; ?>
		</td>
		<td class="eidt"><?php echo $item_amount1; ?>
		</td>
		<td class="eidt"><?php echo $item_pre_weight1; ?>
		</td>
		<td class="eidt"><?php echo $item_madein1; ?>
		</td>
		<td class="eidt"><?php echo $item_pre_price1; ?>
		</td>
		<td class="eidt"><?php echo $item_price1; ?>
		</td>
		<td class="eidt"><?php echo $item_weight1; ?>
		</td>
    </tr>
<?php if($item2_id>0){ ?>	
	<tr>
		<td class="eidt"><?php echo $item_name2; ?>
		</td>
		<td class="eidt"><?php echo $item_amount2; ?>
		</td>
		<td class="eidt"><?php echo $item_pre_weight2; ?>
		</td>
		<td class="eidt"><?php echo $item_madein2; ?>
		</td>
		<td class="eidt"><?php echo $item_pre_price2; ?>
		</td>
		<td class="eidt"><?php echo $item_price2; ?>
		</td>
		<td class="eidt"><?php echo $item_weight2; ?>
		</td>
    </tr>
<?php } ?>

<?php if($item3_id>0){ ?>	
	<tr>
		<td class="eidt"><?php echo $item_name3; ?>
		</td>
		<td class="eidt"><?php echo $item_amount3; ?>
		</td>
		<td class="eidt"><?php echo $item_pre_weight3; ?>
		</td>
		<td class="eidt"><?php echo $item_madein3; ?>
		</td>
		<td class="eidt"><?php echo $item_pre_price3; ?>
		</td>
		<td class="eidt"><?php echo $item_price3; ?>
		</td>
		<td class="eidt"><?php echo $item_weight3; ?>
		</td>
    </tr>	
<?php } ?>	
	</tbody>
</table>  

 
<div align="center"> <input type="button" class="btn" id="cancle_btn" value="返 回" />  </div>

 

<br />

</div>

</body>
</html>